<template>
    <div>
      <header class="site-header jumbotron">
        <div class="container">
          <div class="row">
            <div class="col-xs-12">
              <h1 class="niubi">请发表对Vue的评论</h1>
              <!-- index.html中的资源都可以用，.vue中的需要组件通信 -->
            </div>
          </div>
        </div>
      </header>
      <div class="container">
        <Add :addComment="addComment"/>
        <List :comments="comments" />
      </div>
    </div>
</template>

<script>
  import Add from "./components/Add"
  import  List from "./components/List"
  export default {
    data(){
      return{
       comments:[//数据在哪个组件，跟心数据的行为（方法）就应该定义在哪个组件
         { name:'BOB',
           content:'Vue 还不错',
           test:{
           login:'123'
           }
         },{ name:'BABY',
           content:'Vue So easy',
           test:{
           login:'123'
           }
         },{ name:'TOM',
           content:'Vue just so so',
           test:{
           login:'123'
           }
         },
         {
           name:'TNT',
           content:'yes yes!',
           test:{
             login:'123'
           }
         }
       ]
        }

    },
    methods:{
      //添加评论
      addComment(comment){
        this.comments.unshift(comment)
      }
    },
    components:{
      Add,
      List
    },
  }
</script>

<style scoped>

</style>
